<template>
  <div>
    <van-nav-bar title="收货地址" left-arrow @click-left="onClickLeft" />
    <van-address-edit
      :area-list="areaList"
      show-postal
      show-delete
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
    />
  </div>
</template>

<script>
import { Toast } from "vant";
import { areaList } from "@vant/area-data";
export default {
  data() {
    return {
      areaList,
      addressInfo:{
        name:'',
        tel:'',
        province:'',
        city:'',
        county:'',
        adressDetail:'',
        postalCode:''
      }
    };
  },
  methods: {
    onSave() {
      const { name,tel,province,city,county,adressDetail,postalCode} = this;
        console.log(this);

        const url = "/adress";
        const params = `uname=${this.uname}&pwd=${this.pwd}&phone=${this.phone}&selectTime=${this.selectTime}&tname=${this.tname}`;

        this.axios.post(url, params).then((res) => {
          console.log(res);
          if (res.data.code == 200) {
             Toast("收货地址保存成功");
             this.$router.push("me")           
          } else {
            Toast("添加失败");
          }
        });
    },
    onDelete() {
      Toast("取消修改");
    },
    onClickLeft() {
      this.$router.push("me")
    }, 
  },
};
</script>

<style scoped>
::v-deep .van-icon-arrow-left:before {
  color: black;
}
::v-deep .van-button--danger {
  color: #fff;
  background-color: #a7d500;
  border: 0;
}
</style>